const request = require("./http.js");
//小程序秒杀列表
var getSeckillSkuList = function (data, callback) {
  request({
    url: "/mall/seckill/getSeckillSkuList",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//进入秒杀获取时间
var getsecTime = function (callback) {
  request({
    url: "/mall/seckill/getTime",
    method: "get",
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//秒杀商品详情
var getgoodDetail = function (skuId, callback) {
  request({
    url: "/mall/seckillSku/seckillDetile?skuId=" + skuId,
    method: "get",
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//打包一口价活动名称列表
var getSetMealList = function (data, callback) {
  request({
    url: "/mall/setMeal/activitiesList",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
// 打包一口价商品列表
var getSetMealSkuList = function (data, callback) {
  request({
    url: "/mall/setMealSku/setMealCommodityList",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//拼团活动详情
var getgroupdetail = function (data, callback) {
  request({
    url: "/mall/groupActivitiesSku/getgroupActivitiesDetailes",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//拼团活动列表
var getgroupActivitiesList = function (data, callback) {
  request({
    url: "/mall/groupActivities/getgroupActivitiesListShow",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//拼团预约
var groupActivitiesUserAppointment = function (data, callback) {
  request({
    url: "/mall/groupActivitiesSku/GroupActivitiesUserAppointment",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//小程序优惠券列表
var getCouponList = function (data, callback) {
  request({
    url: "/mall/coupon/getCouponList",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//领取优惠券
var getReceiveCoupon = function (data, callback) {
  request({
    url: "/mall/coupon/getReceiveCoupon",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//查询优惠券详情
var getCouponDetailes = function (data, callback) {
  request({
    url: "/mall/coupon/CouponDetailes",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//订单查询运费
var getOrderFreight = function (data, callback) {
  request({
    url: "/mall/freightTemplate/orderFreight",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//获取购物车商品的优惠券
var getCommodityCoupon = function (data, callback) {
  request({
    url: "/mall/coupon/getCommodityCoupon",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};
//秒杀时间列表获取
var getTimeList = function (data, callback) {
  request({
    url: "/mall/seckill/getTimeList",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
};

const  getLPList = function(data,callback) {
  request({
    url: "/mall/tzGift/selectTzGift",
    method: "post",
    data: data,
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
}

const  getTemplateId = function(callback) {
  request({
    url: "/mall/tbOrder/getTemplateId",
    method: "get",
    data: {},
    success: function (res) {
      callback(res);
    },
    fail: function (err) {
      console.log(err);
      wx.showToast({
        title: err.errMsg,
        icon: "none",
        duration: 2000,
      });
    },
  });
}

module.exports = {
  getTemplateId, //获取通知的模板id
  getLPList, //获取礼品列表
  getSeckillSkuList: getSeckillSkuList, //小程序秒杀列表
  getSetMealList: getSetMealList, //打包一口价活动名称列表
  getSetMealSkuList: getSetMealSkuList, // 打包一口价商品列表
  getsecTime: getsecTime, //进入秒杀获取时间
  getgoodDetail: getgoodDetail, //秒杀商品详情
  getgroupdetail: getgroupdetail, //拼团活动详情
  getgroupActivitiesList: getgroupActivitiesList, //拼团活动列表
  getCouponList: getCouponList, //小程序优惠券列表
  getReceiveCoupon: getReceiveCoupon, //领取优惠券
  groupActivitiesUserAppointment: groupActivitiesUserAppointment, //拼团预约
  getCouponDetailes: getCouponDetailes, //查询优惠券详情
  getOrderFreight:getOrderFreight,//订单查询运费
  getCommodityCoupon:getCommodityCoupon,//获取购物车商品的优惠券
  getTimeList:getTimeList,//秒杀时间列表获取
}